#ifndef __UART_H_
#define __UART_H_

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <termios.h>
#include <string.h>
#include <sys/ioctl.h>
#include <iostream>

class UART{
private:
    int FD;                                                                         //串口对应的文件
    fd_set readfds;
    
public:
    UART(int brate = 115200, const char *dev = "/dev/ttyS9");           //可选 2400 4800 9600 115200
    ~UART();
    int open_port(char *com);                                                       //打开串口对应文件
    int set_opt(int fd,int nSpeed, int nBits, char nEvent, int nStop);              //设置串口参数
    int recv(void* buf, int bufsize);
    int recv(void* buf, int bufsize, struct timeval timeout);                                  
    int send(void* buf, int buf_len);
};

#endif